package org.easy4j.framework.core.meta;

import javax.annotation.processing.*;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic;
import java.util.Set;

/**
 * @author: liuyong
 * @since 1.0
 */
@SupportedAnnotationTypes({"org.easy4j.framework.core.meta.PrintMe"})
public class MetaProcessor extends AbstractProcessor {


    /**
     * {@inheritDoc}
     */
    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
        Messager messager = processingEnv.getMessager();

        for (TypeElement te : annotations) {
            //messager.printMessage(Diagnostic.Kind.ERROR ,"IIIII===========================>" + annotations.getClass().getName() );

            for (Element e : env.getElementsAnnotatedWith(te)) {
                messager.printMessage(Diagnostic.Kind.WARNING, "Printing: " + e.toString());
            }
        }
        return true;
    }

    public synchronized void init(ProcessingEnvironment env) {
        super.init(env);


    }
}
